<template>
  <div class="app-container">

    <!-- 查询和其他操作 -->
    <el-form :inline="true" class="demo-form-inline filter">
      <el-form-item label="用户账号">
        <el-input v-model="listQuery.id" clearable class="filter-item" placeholder="请输入用户账号" />
      </el-form-item>
      <el-form-item label="用户名称">
        <el-input v-model="listQuery.username" clearable class="filter-item" placeholder="请输入用户名称" />
      </el-form-item>
      <el-form-item v-if="this.$store.state.user.fsiteLevel == 3" label="所属地区">
        <el-select disabled v-model="listQuery.fsiteNoBelong" clearable filterable class="filter-item"
          placeholder="请选择所属地区">
          <el-option v-for="item in fsiteNoBelongOptions" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </el-form-item>
      <el-form-item v-else label="所属地区">
        <el-select v-model="listQuery.fsiteNoBelong" clearable filterable class="filter-item" placeholder="请选择所属地区">
          <el-option v-for="item in fsiteNoBelongOptions" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button round size="medium" class="filter-item"
          :style="{ background: buttonColor.lookup, color: buttonColor.color }" @click="handleFilter">查找</el-button>
        <el-button round size="medium" class="filter-item" :style="{ background: buttonColor.add, color: buttonColor.color }"
          @click="handleCreate">添加</el-button>
        <!-- <el-button round size="medium" class="filter-item"
          :style="{ background: buttonColor.export, color: buttonColor.color }" @click="handleExport">导出</el-button>
        <el-button round size="medium" :style="{ background: buttonColor.import, color: buttonColor.color }"
          @click="handleUpload">导入</el-button> -->
      </el-form-item>
    </el-form>

    <!-- 查询结果 -->
    <el-table class="buttonTag" stripe :height="buttonColor.clientHeight" v-loading="listLoading" :data="list"
      :header-cell-style="tableColor" element-loading-text="正在查询中。。。" border fit highlight-current-row>
      <el-table-column align="center" :width="buttonColor.operationThree" label="操作" class-name="small-padding">
        <template slot-scope="scope">
          <div class="operationButton">
            <div :style="{ color: buttonColor.edit, cursor: 'pointer' }" @click="handleUpdate(scope.row)">
              <img src="../../../public/images/edit.png" />
              编辑
            </div>
            <div :style="{ color: buttonColor.delete, cursor: 'pointer' }" @click="handleDelete(scope.row)">
              <img src="../../../public/images/del.png" />
              删除
            </div>
            <div :style="{ color: buttonColor.pwd, cursor: 'pointer' }" @click="handleResetPassword(scope.row)">
              <img src="../../../public/images/pwd.png" />
              密码重置
            </div>
            <div :style="{ color: buttonColor.impower, cursor: 'pointer' }"
              v-show="formatSite2(scope.row.fsiteNoBelong) === 3 || scope.row.roleIds.indexOf(formatRoleName('空气监控大屏')) === 0"
              @click="handlePermission(scope.row)">
              <img src="../../../public/images/impower.png" />
              实验室授权
            </div>
            <div :style="{ color: buttonColor.impower, cursor: 'pointer' }"
              v-show="formatSite2(scope.row.fsiteNoBelong) === 3 || scope.row.roleIds.indexOf(formatRoleName('空气监控大屏')) === 0"
              @click="handlePermissionGui(scope.row)">
              <img src="../../../public/images/impower.png" />
              管理柜授权
            </div>
          </div>
        </template>
      </el-table-column>
      <el-table-column :width="buttonColor.line" :index="indexMethod" align="center" label="序号" type="index" sortable />
      <el-table-column width="80" align="left" label="用户账号" prop="id" />
      <el-table-column :width="buttonColor.name" align="left" label="用户名称" prop="username" />
      <el-table-column align="left" label="用户角色" prop="roleIds">
        <template slot-scope="scope">
          <el-button v-for="roleId in scope.row.roleIds" :key="roleId" class="button-new-tag" size="small"
            style="margin-right: 20px;"> {{ formatRole(roleId) }} </el-button>
        </template>
      </el-table-column>
      <el-table-column width="180" :formatter="formatSite" align="left" label="所属地区" prop="fsiteNoBelong" />
      <el-table-column width="112" align="left" label="手机" prop="phone" />
      <el-table-column align="left" label="邮箱" prop="email" />
      <el-table-column align="left" label="卡号" prop="fcard" />
      <el-table-column :width="buttonColor.state" align="left" label="用户类型" prop="ftype">
        <template slot-scope="scope">
          <span :style="{ color: buttonColor.typeback }" v-if="scope.row.ftype === 1">{{ scope.row.ftype | userTypeFilter
          }}</span>
          <span :style="{ color: buttonColor.typefront }" v-else-if="scope.row.ftype === 2">{{ scope.row.ftype |
              userTypeFilter
          }}</span>
          <span :style="{ color: buttonColor.typeall }" v-else>{{ scope.row.ftype | userTypeFilter }}</span>
        </template>
      </el-table-column>
      <el-table-column :width="buttonColor.state" align="left" label="状态" prop="status">
        <template slot-scope="scope">
          <span :style="{ color: buttonColor.statedisable }" v-if="scope.row.status == 0">{{ scope.row.status | statusFilter
          }}</span>
          <span :style="{ color: buttonColor.statestart }" v-else>{{ scope.row.status | statusFilter }}</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit"
      @pagination="getList" />

    <!-- 添加或修改对话框 -->
    <el-dialog :close-on-click-modal="false" :visible.sync="dialogFormVisible" width="auto">
      <template slot="title">
        <div :style="titleColor">{{ textMap[dialogStatus] }}</div>
      </template>
      <el-form ref="dataForm" :rules="rules" :model="dataForm" status-icon label-position="left" label-width="80px">
        <el-row>
          <el-col :span="12">
            <el-form-item class="required" label="用户账号" prop="id">
              <el-input v-if="dialogStatus === 'create'" v-model="dataForm.id" type="number" />
              <!-- oninput="value=value.replace(/[^\d]/g,'')"-->
              <el-input v-else :disabled="true" v-model="dataForm.id" type="number" />
              <!-- oninput="value=value.replace(/[^\d]/g,'')"-->
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item class="el-form-item-small" label="状态" prop="status">
              <el-select v-model="dataForm.status" class="filter-item" placeholder="请选择状态">
                <el-option v-for="(key, value) in statusMap" :key="key" :label="key" :value="value" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item class="required" label="用户名称" prop="username">
              <el-input v-model="dataForm.username" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item class="required" label="所属地区" prop="fsiteNoBelong">
              <el-select v-model="dataForm.fsiteNoBelong" filterable placeholder="请选择">
                <!-- @change="listPoint(dataForm.fsiteNoBelong)"-->
                <el-option v-for="item in fsiteNoBelongOptions" :key="item.value" :label="item.label"
                  :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item class="required" label="用户角色" prop="roleIds">
              <el-select v-model="dataForm.roleIds" multiple placeholder="请选择">
                <el-option v-for="item in roleOptions" :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item class="el-form-item-small required" label="用户类型" prop="ftype">
              <el-select v-model="dataForm.ftype" class="filter-item" placeholder="请选择用户类型">
                <el-option v-for="(key, value) in userTypeMap" :key="key" :label="key" :value="value" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item class="required" label="手机" prop="phone">
              <el-input v-model="dataForm.phone" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item class="required" label="邮箱" prop="email">
              <el-input v-model="dataForm.email" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="卡号" prop="fcard">
              <el-input v-model="dataForm.fcard" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="平台编号" prop="nickName">
              <el-input v-model="dataForm.nickName" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item class="text" style="width: 100%" label="备注" prop="note">
              <el-input v-model="dataForm.note" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button round size="medium" :style="{ background: buttonColor.cancel, color: buttonColor.colorone }"
          @click="dialogFormVisible = false">取消</el-button>
        <el-button round size="medium" v-if="dialogStatus == 'create'"
          :style="{ background: buttonColor.confirm, color: buttonColor.color }" @click="createData">确定</el-button>
        <el-button round size="medium" v-else :style="{ background: buttonColor.confirm, color: buttonColor.color }"
          @click="updateData">确定</el-button>
      </div>
    </el-dialog>

    <!-- 导出弹窗 -->
    <el-dialog width="auto" :close-on-click-modal="false" :visible.sync="uploadVisible">
      <template slot="title">
        <div :style="exportColor">用户资料</div>
      </template>
      <div style="width:300px;height:200px;display: flex;flex-direction: column;align-items: center">
        <el-upload :on-success="uploadFileSuccess" :headers="headers" :action="uploadPath2"
          :data="{ 'tableName': 'import_i_ts_admin' }" :show-file-list="false" class="filter-item" style="margin-top:20px"
          accept=".xlsx">
          <el-button round size="medium" icon="el-icon-upload"
            :style="{ background: buttonColor.import, color: buttonColor.color }">导入</el-button>
        </el-upload>
        <div style="margin-top:30px;text-decoration:underline">
          <a :href="downUrl" style="color: blue">模板文件下载</a>
        </div>

      </div>
    </el-dialog>

    <!-- 权限配置对话框 :props="defaultProps"  -->
    <el-dialog width="400px" :close-on-click-modal="false" :visible.sync="permissionDialogFormVisible">
      <template slot="title">
        <div :style="titleColor">实验室权限</div>
      </template>
      <el-tree style="height:400px !important;overflow:auto !important;padding: 0 20px !important" ref="tree2"
        :data="systemPermissions" :default-checked-keys="assignedPermissions" show-checkbox node-key="id" />
      <div slot="footer" class="dialog-footer">
        <el-button round :style="{ background: buttonColor.cancel, color: buttonColor.colorone }"
          @click="permissionDialogFormVisible = false">取消</el-button>
        <el-button round :style="{ background: buttonColor.confirm, color: buttonColor.color }" @click="updatePermission">确定
        </el-button>
      </div>
    </el-dialog>

    <!-- 管理柜权限配置对话框 :props="defaultProps"  -->
    <el-dialog width="400px" :close-on-click-modal="false" :visible.sync="permissionDialogFormVisibleGui">
      <template slot="title">
        <div :style="titleColor">管理柜权限</div>
      </template>
      <el-tree style="height:400px !important;overflow:auto !important;padding: 0 20px !important" ref="tree3"
        :data="systemPermissionsGui" :default-checked-keys="assignedPermissionsGui" show-checkbox node-key="id" />
      <div slot="footer" class="dialog-footer">
        <el-button round :style="{ background: buttonColor.cancel, color: buttonColor.colorone }"
          @click="permissionDialogFormVisibleGui = false">取消</el-button>
        <el-button round :style="{ background: buttonColor.confirm, color: buttonColor.color }" @click="updatePermissionGui">
          确定</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<style>
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.avatar-uploader .el-upload:hover {
  border-color: #20a0ff;
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 120px;
  height: 120px;
  line-height: 120px;
  text-align: center;
}

.avatar {
  width: 145px;
  height: 145px;
  display: block;
}
</style>

<script>
import { listAdmin, createAdmin, updateAdmin, deleteAdmin, resetPassword, exportXsl } from '@/api/admin'
import { uploadPath2 } from "@/api/area";
import { getApiUrl } from '@/utils/request'
import { roleOptions, fsiteNoBelongOptions } from '@/api/role'
import { uploadPath } from '@/api/storage'
import { listArea } from '@/api/area'
import { getToken } from '@/utils/auth'
import Pagination from '@/components/Pagination'
import { listPointByFsiteNo2, getPermissions, updatePermission, getPermissionsBox, updatePermissionBox } from '@/api/airAlarm'
import { tableColor, titleColor, buttonColor, exportColor } from '@/filters/index'

const userTypeMap = {
  1: '后端',
  2: '前端',
  3: '全部'
}
const statusMap = {
  0: '禁用',
  1: '启用'
}
export default {
  name: 'Admin',
  components: { Pagination },
  filters: {
    userTypeFilter(type) {
      return userTypeMap[type]
    },
    statusFilter(type) {
      return statusMap[type]
    }
  },
  data() {
    return {
      downUrl: null,
      exportColor,
      uploadPath2,
      uploadVisible: false,
      buttonColor,
      uploadPath,
      list: null,
      total: 0,
      roleOptions: null,
      fsiteNoBelongOptions: null,
      atsSites: null,
      atsPoints: null,
      permissionDialogFormVisible: false,
      systemPermissions: null,
      assignedPermissions: null,
      permissionForm: {
        userId: undefined,
        permIds: []
      },
      permissionDialogFormVisibleGui: false,
      systemPermissionsGui: null,
      assignedPermissionsGui: null,
      permissionFormGui: {
        userId: undefined,
        permIds: []
      },
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 20,
        id: undefined,
        username: undefined,
        roleIds: undefined,
        fsiteNoBelong: undefined,
        ftype: undefined,
        sort: 'create_time',
        order: 'desc'
      },
      listQuery2: {
        fsiteLevel: 3
      },
      userTypeMap,
      statusMap,
      dataForm: {
        id: undefined,
        username: undefined,
        fsiteNoBelong: undefined,
        phone: undefined,
        fcard: undefined,
        nickName: undefined,
        note: undefined,
        email: undefined,
        roleIds: [],
        fpointNoesVo: [],
        atsPoints: []
      },
      dialogFormVisible: false,
      dialogStatus: '',
      textMap: {
        update: '编辑',
        create: '创建'
      },
      tableColor: tableColor,
      titleColor: titleColor,
      rules: {
        id: [
          { required: true, message: '用户账号不能为空', trigger: 'blur' }
        ],
        username: [
          { required: true, message: '用户名称不能为空', trigger: 'blur' }
        ],
        roleIds: [
          { required: true, message: '用户角色不能为空', trigger: 'blur' }
        ],
        fsiteNoBelong: [
          { required: true, message: '所属地区不能为空', trigger: 'blur' }
        ],
        ftype: [
          { required: true, message: '用户类型不能为空', trigger: 'blur' }
        ],
        phone: [
          { required: true, message: '手机不能为空', trigger: 'blur' }
        ],
        email: [
          { required: true, message: '邮箱不能为空', trigger: 'blur' }
        ]
      },
      downloadLoading: false
    }
  },
  computed: {
    headers() {
      return {
        'Authorization': getToken()
      }
    }
  },
  created() {
    this.downUrl = getApiUrl() + 'xlsx/1-7用户资料.xlsx'
    if (this.$store.state.user.fsiteLevel == 3) {
      this.listQuery.fsiteNoBelong = this.$store.state.user.fsiteNo
    }
    this.getList()
    roleOptions()
      .then(response => {
        this.roleOptions = response.data.data.list
      })
      .catch(() => {
        this.roleOptions = []
      })
    fsiteNoBelongOptions()
      .then(response => {
        this.fsiteNoBelongOptions = response.data.data.list
      })
      .catch(() => {
        this.fsiteNoBelongOptions = []
      })
    listArea(this.listQuery2)
      .then(response => {
        this.atsSites = response.data.data.list
      })
      .catch(() => {
        this.atsSites = []
      })
  },
  methods: {
    // 导入
    uploadFileSuccess: function (response) {
      this.uploadVisible = false
      this.$notify.success({
        title: '导入',
        dangerouslyUseHTMLString: true,
        message: response.data
      })
    },
    handleUpload() {
      this.uploadVisible = true
    },

    listPoint(fsiteNo) {
      listPointByFsiteNo2(fsiteNo)
        .then(response => {
          this.atsPoints = response.data.data.list
        })
        .catch(() => {
          this.atsPoints = []
        })
    },
    formatRole(roleId) {
      if (this.roleOptions) {
        for (let i = 0; i < this.roleOptions.length; i++) {
          if (roleId === this.roleOptions[i].value) {
            return this.roleOptions[i].label
          }
        }
        return ''
      } else {
        return ''
      }
    },
    formatRoleName(roleName) {
      if (this.roleOptions) {
        for (let i = 0; i < this.roleOptions.length; i++) {
          if (roleName === this.roleOptions[i].label) {
            return this.roleOptions[i].value
          }
        }
        return ''
      } else {
        return ''
      }
    },
    formatSite2(fsiteNo) {
      if (this.atsSites) {
        for (let i = 0; i < this.atsSites.length; i++) {
          if (fsiteNo === this.atsSites[i].fsiteNo) {
            return this.atsSites[i].fsiteLevel
          }
        }
        return ''
      } else {
        return ''
      }
    },
    formatStatus: function (row, column) {
      return row.status === 1 ? '启用' : '禁用'
    },
    formatSite: function (row, column) {
      if (this.fsiteNoBelongOptions) {
        for (let i = 0; i < this.fsiteNoBelongOptions.length; i++) {
          if (row.fsiteNoBelong === this.fsiteNoBelongOptions[i].value) {
            return this.fsiteNoBelongOptions[i].label
          }
        }
        return ''
      } else {
        return ''
      }
    },
    getList() {
      this.listLoading = true
      listAdmin(this.listQuery)
        .then(response => {
          this.list = response.data.data.list
          this.total = response.data.data.total
          this.listLoading = false
        })
        .catch(() => {
          this.list = []
          this.total = 0
          this.listLoading = false
        })
    },
    handleFilter() {
      this.listQuery.page = 1
      this.getList()
    },
    resetForm() {
      this.dataForm = {
        id: undefined,
        username: undefined,
        fsiteNoBelong: undefined,
        phone: undefined,
        fcard: undefined,
        nickName: undefined,
        note: undefined,
        email: undefined,
        roleIds: [],
        fpointNoesVo: [],
        atsPoints: []
      }
    },
    handleCreate() {
      this.resetForm()
      this.dialogStatus = 'create'
      this.dataForm.status = '1'
      this.dialogFormVisible = true
      this.atsPoints = null
      this.$nextTick(() => {
        this.$refs['dataForm'].clearValidate()
      })
    },
    createData() {
      this.$refs['dataForm'].validate(valid => {
        if (valid) {
          createAdmin(this.dataForm)
            .then(response => {
              this.list.unshift(response.data.data)
              this.dialogFormVisible = false
              this.$notify.success({
                title: '成功',
                message: '添加用户成功'
              })
            })
            .catch(response => {
              this.$notify.error({
                title: '失败',
                message: response.data.msg
              })
            })
        }
      })
    },
    handleUpdate(row) {
      this.dataForm = Object.assign({}, row)
      this.dataForm.ftype = row.ftype.toString()
      this.dataForm.status = row.status.toString()
      this.dialogStatus = 'update'
      this.dialogFormVisible = true
      this.$nextTick(() => {
        this.$refs['dataForm'].clearValidate()
      })
    },
    handleResetPassword(row) {
      this.$confirm('是否要重置' + row.username + '用户密码', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        resetPassword(row)
          .then(response => {
            this.$notify.success({
              title: '成功',
              message: '重置' + row.username + '用户密码成功，初始密码[' + response.data.data + ']'
            })
          })
          .catch(response => {
            this.$notify.error({
              title: '失败',
              message: response.data.msg
            })
          })
      })
    },
    updateData() {
      this.$refs['dataForm'].validate(valid => {
        if (valid) {
          updateAdmin(this.dataForm)
            .then(() => {
              for (const v of this.list) {
                if (v.id === this.dataForm.id) {
                  const index = this.list.indexOf(v)
                  this.dataForm.status = parseInt(this.dataForm.status)
                  this.list.splice(index, 1, this.dataForm)
                  break
                }
              }
              this.dialogFormVisible = false
              this.$notify.success({
                title: '成功',
                message: '更新用户成功'
              })
            })
            .catch(response => {
              this.$notify.error({
                title: '失败',
                message: response.data.msg
              })
            })
        }
      })
    },
    handleDelete(row) {
      this.$confirm('是否要删除该用户', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteAdmin(row)
          .then(response => {
            this.$notify.success({
              title: '成功',
              message: '删除用户成功'
            })
            const index = this.list.indexOf(row)
            this.list.splice(index, 1)
          })
          .catch(response => {
            this.$notify.error({
              title: '失败',
              message: response.data.msg
            })
          })
      })
    },
    handleExport(row) {
      this.$confirm('是否要导出数据', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        exportXsl(this.dataForm)
          .then(response => {
            this.$notify.success({
              title: '成功',
              message: '导出成功'
            })
          })
          .catch(response => {
            this.$notify.error({
              title: '失败',
              message: response.data.msg
            })
          })
      })
    },
    handlePermission(row) {
      this.permissionDialogFormVisible = true
      this.permissionForm.userId = row.id
      getPermissions(row.id, row.fsiteNoBelong)
        .then(response => {
          this.systemPermissions = response.data.data.all
          this.assignedPermissions = response.data.data.assigned
        })
        .catch(() => {
          this.systemPermissions = []
          this.assignedPermissions = []
        })
      /* this.systemPermissions = [{
        id: 1,
        label: '一级 1',
        children: [{
          id: 4,
          label: '二级 1-1',
          children: [{
            id: 9,
            label: '三级 1-1-1'
          }, {
            id: 10,
            label: '三级 1-1-2'
          }]
        }]
      }, {
        id: 2,
        label: '一级 2',
        children: [{
          id: 5,
          label: '二级 2-1'
        }, {
          id: 6,
          label: '二级 2-2'
        }]
      }, {
        id: 3,
        label: '一级 3',
        children: [{
          id: 7,
          label: '二级 3-1'
        }, {
          id: 8,
          label: '二级 3-2'
        }]
      }]*/
    },
    updatePermission() {
      this.permissionForm.permIds = this.$refs.tree2.getCheckedKeys(false)
      updatePermission(this.permissionForm)
        .then(response => {
          this.permissionDialogFormVisible = false
          this.$notify.success({
            title: '成功',
            message: '授权成功'
          })
        })
        .catch(response => {
          this.$notify.error({
            title: '失败',
            message: response.data.msg
          })
        })
    },
    handlePermissionGui(row) {
      this.permissionDialogFormVisibleGui = true
      this.permissionFormGui.userId = row.id
      console.log('row', row);
      getPermissionsBox(row.id, row.fsiteNoBelong)
        .then(response => {
          this.systemPermissionsGui = response.data.data.all
          this.assignedPermissionsGui = response.data.data.assigned
        })
        .catch(() => {
          this.systemPermissionsGui = []
          this.assignedPermissionsGui = []
        })
    },
    updatePermissionGui() {
      this.permissionFormGui.permIds = this.$refs.tree3.getCheckedKeys(false)
      console.log('this.permissionFormGui.permIds', this.permissionFormGui.permIds);
      updatePermissionBox(this.permissionFormGui)
        .then(response => {
          this.permissionDialogFormVisibleGui = false
          this.$notify.success({
            title: '成功',
            message: '授权成功'
          })
        })
        .catch(response => {
          this.$notify.error({
            title: '失败',
            message: response.data.msg
          })
        })
    },
    indexMethod(index) {
      index = index + 1
      return index
    }
  }
}
</script>

<style>
/*处理input type = number的上下箭头*/
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

input[type="number"] {
  -moz-appearance: textfield;
}
</style>
